473,427 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,427 software developers and data experts.

Adding a context menu to a treeview

How can I use the designer to add a context menu to a class which inherits
from a control, e.g. treeview, without adding the context menu to a form?

For example, to add a context menu with "Select All" and "Clear Selection"
to a checked list box?

Thanks,
Aaron Queenan.
Nov 15 '05 #1
4 14154
The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.

--
Bela Istok
MVP C#
Caracas, Venezuela
"Aaron Queenan" <aq*********************@contingent.com.au> wrote in message
news:uW*************@TK2MSFTNGP12.phx.gbl...
How can I use the designer to add a context menu to a class which inherits
from a control, e.g. treeview, without adding the context menu to a form?

For example, to add a context menu with "Select All" and "Clear Selection"
to a checked list box?

Thanks,
Aaron Queenan.

Nov 15 '05 #2
> The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.


Thanks, Bela. I've tried creating a class that inherits from treeview, and
adding the context menu, but for some reason, when I click "Edit menu",
either nothing happens, or the "null reference" error appears. Does it work
okay in your setup? Maybe my VC.NET 2003 installation is broken.

A similar question: I've managed to add the context menu to the treeview
using the old copy/paste methodology, but is there any way to make the
shortcuts work? For example, if I add Ctrl-A to select all items, it works
fine when the menu is popped up, but doesn't work otherwise. Without
handling each keypress event, is there any way to have the menu
automatically handle the shortcuts while the control is focussed?

Thanks,
Aaron.
Nov 15 '05 #3
Sorry, it's don't work well, I put a user control put the menu in the user control edit the menu, and later change the class from user control to ListView and work well, (I think it a little weird), I guest that it's better do it in code, that this way, but it's almost a way, the problem it's because ListView don't have a design surface.



The answer to your second question it's that for default the shortcuts in the context menu don't get called until the menu it's visible, you can put the shortcuts in a Main Menu Item, and it will work.
--
Bela Istok
MVP C#
Caracas, Venezuela
"Aaron Queenan" <aq*********************@contingent.com.au> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.


Thanks, Bela. I've tried creating a class that inherits from treeview, and
adding the context menu, but for some reason, when I click "Edit menu",
either nothing happens, or the "null reference" error appears. Does it work
okay in your setup? Maybe my VC.NET 2003 installation is broken.

A similar question: I've managed to add the context menu to the treeview
using the old copy/paste methodology, but is there any way to make the
shortcuts work? For example, if I add Ctrl-A to select all items, it works
fine when the menu is popped up, but doesn't work otherwise. Without
handling each keypress event, is there any way to have the menu
automatically handle the shortcuts while the control is focussed?

Thanks,
Aaron.
Nov 15 '05 #4
Thanks, Bela.

Unfortunately, I can't put the menu into the main menu, because it's a dialogue box for an Excel Plug-in.

On the plus side, I've tried assigning the ContextMenu property of the TreeView control, which solves the right-click problems, and some of the accelerators work. Ctrl-A works for selecting all, but Del doesn't work for some reason.

Aaron.
"Bela Istok" <be****@hotmail.com> wrote in message news:OF**************@TK2MSFTNGP10.phx.gbl...
Sorry, it's don't work well, I put a user control put the menu in the user control edit the menu, and later change the class from user control to ListView and work well, (I think it a little weird), I guest that it's better do it in code, that this way, but it's almost a way, the problem it's because ListView don't have a design surface.



The answer to your second question it's that for default the shortcuts in the context menu don't get called until the menu it's visible, you can put the shortcuts in a Main Menu Item, and it will work.
--
Bela Istok
MVP C#
Caracas, Venezuela
"Aaron Queenan" <aq*********************@contingent.com.au> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
The only way to add a ContexMenu it's to add the ContexMenu in the Form or
do it in code, or you can add a class that inherits from treeview, and add
the contex menu in your class in the designer.


Thanks, Bela. I've tried creating a class that inherits from treeview, and
adding the context menu, but for some reason, when I click "Edit menu",
either nothing happens, or the "null reference" error appears. Does it work
okay in your setup? Maybe my VC.NET 2003 installation is broken.

A similar question: I've managed to add the context menu to the treeview
using the old copy/paste methodology, but is there any way to make the
shortcuts work? For example, if I add Ctrl-A to select all items, it works
fine when the menu is popped up, but doesn't work otherwise. Without
handling each keypress event, is there any way to have the menu
automatically handle the shortcuts while the control is focussed?

Thanks,
Aaron.
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ed Sutton | last post by:
I am dynamically appending to a context menu when user right mouse clicks on a treeView. The first time I right-mouse click I see the appended menu. Subsequently, the menu items I append do not...
4
by: Phill | last post by:
Here's what I'm doing to make the right context mnue show up based on what node was cliked: private void tvwMenu_MouseUp(object sender, MouseEventArgs e) { //Select Node When Right Clicked &...
5
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
10
by: tmaster | last post by:
When I try to dynamically add a second sub menu item to this ContextMenu item, I get an error 'Specified argument was out of the range of valid values'. Private Sub mnuTopics_Show_Select(ByVal...
1
by: Chris Murphy via DotNetMonster.com | last post by:
Hi all, I'm just wondering if any one can help me with this development issue I'm having. I've created a customized treeview control to handle the particular tasks to which I'll be using it. Within...
2
by: Lucky | last post by:
hi guys, i'm working on the context menu for the controls. the problem i'm facing right now is like this : i want to use one context menu for more then one controls lets say i want to use one...
2
by: Ron M. Newman | last post by:
Hi, Just need a little advice. Id like to build *dynamic* context menus for tree nodes. I'm pretty versed in building context menus and attaching them to tree nodes. My question is, what...
2
by: Claire | last post by:
I've a treeview control containing a root node with several children on a windows form. I select a node with a left mouse button click. I then select one of the other nodes with right mouse click...
2
by: Bry | last post by:
I have a context menu which is shared between a TreeView and ListView control (both controls show the same information, similar to how Windows Explorer works, so it makes sense to use the same menu...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.